package com.ymkj.testdemo.controller;

import com.ymkj.testdemo.websocket.WebSocketServer;
import com.ymkj.testdemo.websocket.WebSocketServer2;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/checkcenter2")
public class CheckCenterController2 {

	//页面请求
	@GetMapping("/socket/{cid}")
	public String socket(@PathVariable String cid) {
		return cid;
	}
	//推送数据接口
	@ResponseBody
	@RequestMapping("/socket/push/{cid}")
	public String pushToWeb(@PathVariable String cid,String message) {
		try {
			WebSocketServer2.sendInfo(message,cid);
		} catch (IOException e) {
			e.printStackTrace();
			return "error"+cid+"#"+e.getMessage();
		}  
		return "success:"+cid+","+message;
	} 
} 
